package com.shenyue.nbtownlet.activity;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.os.Handler;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.shenyue.nbtownlet.R;
import com.shenyue.nbtownlet.base.BaseActivity;
import com.shenyue.nbtownlet.databinding.ActivityOfficeCheckDetailBinding;
import com.shenyue.nbtownlet.event.BaseListener;
import com.shenyue.nbtownlet.model.AppInsertTaskModel;
import com.shenyue.nbtownlet.model.DefaultModel;
import com.trycatch.mysnackbar.Prompt;
import com.trycatch.mysnackbar.TSnackbar;

/**
 * 公文查收详情
 */
public class OfficeCheckDetailActivity extends BaseActivity implements BaseListener {
    private ActivityOfficeCheckDetailBinding binding;
    private Context mContext;
    private Handler mHandler = new Handler();
    private String InstanceID;
    private TSnackbar snackBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        binding = DataBindingUtil.setContentView(this, R.layout.activity_office_check_detail);
        setActionBar(true, getString(R.string.tv_office_check) + "详情");
        mContext = this;

        Bundle bundle = getIntent().getExtras();
        InstanceID = bundle.getString(DefaultModel.PAGE_DATA_ID);

        snackBar = showTSnackbar("正在查询数据..., 请稍候");
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                findDetail();
            }
        }, 32);
    }

    private void findDetail() {
        JSONObject param = new JSONObject();
        param.put("id", InstanceID);
        AppInsertTaskModel.getDetailWorkByID(mContext, param, this);
    }

    @Override
    public void success(String val, String action) {
        if (AppInsertTaskModel.GETDETAILWORKBYID_ACTION.equals(action)) {
            hideTSnackbar(snackBar, "数据查询成功");

        }
    }

    @Override
    public void error(String error, String action) {
        hideTSnackbar(snackBar, error, Prompt.WARNING);
    }
}
